package com.nioSocketCore.chapter02;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.InetSocketAddress;
import java.nio.channels.DatagramChannel;
import java.nio.channels.FileChannel;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

public class NormalChannel {

    private final  static int PORT = 8848;

    public static void main(String[] args) throws IOException {
        SocketChannel sc = SocketChannel.open( );
        sc.connect (new InetSocketAddress ("somehost", PORT));   // 通过 socketChannel.open 获取  客户端 channel

        ServerSocketChannel ssc = ServerSocketChannel.open( );    // 通过 ServerSocketChannel.open 获取服务端 channel
        ssc.socket( ).bind (new InetSocketAddress(PORT));

        DatagramChannel dc = DatagramChannel.open( );    //获取 udp channel

        RandomAccessFile raf = new RandomAccessFile("somefile", "r");  // 获取 文件channel

        FileChannel fc = raf.getChannel( );
    }
}
